<?php
include('lib/db_connection.php');
$veh = $_GET["veh"];
$company_id = $_SESSION['company_id'];

$result_comp = mysql_query("SELECT * FROM company_tbl WHERE company_id='".$company_id."'")
or die("SELECT COMPANY ".mysql_error());
$row_comp = mysql_fetch_array($result_comp);

function commafy($_)
       {
        return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,' , strrev( $_ ) ) );
       }
?>
<html>
<head>
</head>
<body style='background-color:#FFFFFF' onLoad='window.print()'>
<table border='0' width='810' style='margin-left:auto;margin-right:auto;font-size:14px;font-family:Times New Roman'>
<tr>
 <th width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['company_name']?></th>
</tr>
<tr>
 <th width='100%' style='text-align:center;' colspan='3'><?php echo $row_comp['address']?></th>
</tr>
<tr>
 <td width='33%' style='text-align:left;'>Contact No:<?php echo $row_comp['contact_no']?></td>
 <td width='34%' style='text-align:center;'><?php echo $row_comp['website']?></td>
 <td width='33%' style='text-align:right;'>Fax No:<?php echo $row_comp['fax_no']?></td>
</tr>
</table>


<?php
$query_veh = "SELECT * FROM vehicle_tbl WHERE company_id='".$company_id."' and out_of_service=0";
$result_veh = mysql_query($query_veh);
$row_vehicles = mysql_fetch_array($result_veh);
?>
	<div style="width: 100%; text-align: center;"><img border="0" src="image/active_veh_list.png" width="810" height="30" /></div>

<table border='1' width='810' style='margin-left:auto;margin-right:auto;font-size:14px;font-family:Times New Roman'>
<tr>
	<th style='width:15%'>Plate Number</th>
	<th style='width:15%'>Year</th>
	<th style='width:25%'>Make</th>
	<th style='width:25%'>Model</th>
	<th style='width:20%'>Km/Hrs</th>
</tr>
<?php
$query_list = "SELECT * FROM vehicle_tbl WHERE company_id='".$company_id."' and out_of_service=0";
$result_list = mysql_query($query_list) or die("LIST ".mysql_error());
while($row_list = mysql_fetch_array($result_list))
{
if($row_list['track_by']=='hours')
{
$mileage = $row_list['curr_hours'];
$lbl = 'Hrs';
}
if($row_list['track_by']=='distance')
{
$mileage = $row_list['curr_tracking_value'];
$lbl = 'Km';
}
?>
<tr>
	<td style='text-align:center'><?php echo $row_list['veh_num']?></td>
	<td style='text-align:center'><?php echo $row_list['year']?></td>
	<td style='text-align:center'><?php echo $row_list['manufacturer_name']?></td>
	<td style='text-align:center'><?php echo $row_list['model_name']?></td>
	<td style='text-align:center'><?php echo $mileage.$lbl?></td>
</tr>
<?php
}
?>
</table>
<p style=" position: relative; bottom: 0; left: 0; width: 100%; text-align: center;"><img border="0" src="image/footer_wo.png" width="135" height="30" style='margin-left:auto;margin-right:auto'/></p>
</body>
</html>
